package com.demo.tuling.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Component
public class UserService {
    @Resource
//    @Lazy
    private UserService userService;
    @Autowired
    private JdbcTemplate jdbcTemplate;

//    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void test(){
        jdbcTemplate.execute("insert into t1(name,age) values('hhhh', 99)");
        this.a();
        userService.a();
//        throw new NullPointerException();

    }
//    @Transactional(propagation = Propagation.NEVER, rollbackFor = Exception.class)
    public void a(){
        jdbcTemplate.execute("insert into t1(name,age) values('aaaa', 10)");
    }



}
